extends layout

block content
    h1= title
    form(method='post' action='')
        div.form-group
            label(for='title') 书名:
            input#title.form-control(type='text', placeholder='please input title', name='title', value=(undefined===book?'':book.title), required='true')
        div.form-group
            label(for='author') 作者:
            select#author.form-control(type='select', placeholder='please select author', name='author', required='true')
                for author in authors
                    if book
                        option(value=author._id selected=(author._id.toString()===book.author.toString()?'selected':false)) #{author.name}
                    else
                        option(value=author._id) #{author.name}
        div.form-group
            label(for='summary') Summary:
            input#summary.form-control(type='text' name='summary' value=(undefined === book ? '' : book.summary) required='true')
        div.form-group
            label(for='isbn') ISBN
            input#isbn.form-control(type='text' name='isbn' placeholder='ISBN13' value=(book === undefined ? '' : book.isbn))
        div.form-group
            label Genre
            div
                for genre in genres
                    div(style='display:inline;padding-right:10px;')
                    input.checkbox-input(type='checkbox' name='genre' id=genre._id value=genre._id checked=genre.checked)
                    label(for=genre._id) #{genre.name}
        button.btn.btn-primary(type='submit') 提交

    if errors
        ul
            for error in errors
                li!=error.msg